<template>
    <div>
        <table>
            <tr>
                <th>编号</th>
                <th>图书名称</th>
                <th>作者</th>
            </tr>
            <tr v-for="item in books">
                <td>{{item.id}}</td>
                <td>{{item.name}}</td>
                <td>{{item.author}}</td>
            </tr>
        </table>
    </div>
</template>

<script>
    export default {
        name: "Book",
        data() {
            return {
                msg: 'Hello Vue',
                books: [
                    {
                        id: 1,
                        name: 'Java零基础实战',
                        author: '宁楠'
                    },
                    {
                        id: 2,
                        name: 'Vue零基础实战',
                        author: '张三'
                    },
                    {
                        id: 3,
                        name: 'Spring零基础实战',
                        author: '小狂'
                    }
                ]
            }
        },
        // 初始化操作，页面加载前初始化
        created() {
            const _this = this;
            axios.get('http://localhost:8181/book/findAll').then(function (response) {
                _this.books = response.data;
            })
        }
    }
</script>

<style scoped>

</style>